<template lang="jade">
div.search.cbox
	li.input
		dl.cbox.ptype
			dd(v-bind:class="{ 'on': productype == 'current'}",v-on:click="setList('current')") 在投标
			dd(v-bind:class="{ 'on': productype == 'review'}",v-on:click="setList('review')") 往期标
			dd(v-bind:class="{ 'on': productype == 'group'}",v-on:click="setList('group')") 房利宝

	li.btn
		i.iconfont &#xe62b;

div#productlist.top.bottom
	ul.productlist
		li(:is="productype", :productype="productype", v-for="(index, item) in items | filterBy getTypeByMenu", :item="item")
	div.loading(v-if="busy")
		span 数据加载中...
</template>

<script>
import '../../assets/sass/common/circle.scss'
import CssCircle from '../../v-circle/components/css-circle.vue'
import ProductView from '../../components/index/product'
import ReviewView from '../../components/index/product'
import GroupView from '../../components/index/product'
import {Api_Index, Api_Group_List} from '../../config/api'

export default{
	props:['item'],

    created() {
        this.fetch(1);
    },

	data(){
		return{
			productype:"current",
			busy:true,
			items: [],
			obj: [],
			page:1
		}
	},
	components: {
		circleCss: CssCircle,
		current:ProductView,
		review:ReviewView,
		group:GroupView
	},

	methods:{

	    setList: function (key) {
			this.productype = key;
			this.busy = true;
			this.items=this.obj=[];
			this.page=1;
			if(key=='current' || key =="review")
				this.fetch(1);
			else
				this.group_fetch(1);
			//this.$dispatch('show_data');
	    },


	    fetch: function (page) {
	      var data = {'page': page}
	      this.$http({url: Api_Index+'&page='+page+'&tender='+this.productype, method: 'GET'}).then(function (response) {
	        this.productype = response.data.type;
	        //this.productype = "group";
	        this.banlance = response.data.banlance;
	        this.items = this.items.concat(response.data.data);
	        this.obj = Object.assign([], this.obj.concat(response.data.data));
	        this.busy = false;
	        //this.getType(this.showTypeNum);
	      });
	    },


		group_fetch: function (page) {

		  this.productype = 'group';
		  var data = {'page': page}
		  this.$http({url:Api_Group_List+'&page='+page, method:'GET'}).then(function(rs){


		      var data = rs.data.data
		      if(data){
		        this.items = this.items.concat(rs.data.data);
		        //this.obj = Object.assign([], this.obj.concat(rs.data.data));
		        this.obj = Object.assign([], this.obj.concat(rs.data.data));
		      }
		      this.busy = false;

		  });


		}
	}
}
</script>